import {str2Arr} from './common'

//对后台接收到的数据进行需要的格式处理
export let dataTransation = (obj) => {
    const url = 'http://misc.opencai.net/for-opencai/v2/logos/';
    // console.log(obj);
    // console.log(obj.data[0]);
    // let obj = {
    //     rows: 1,
    //     code: "ssq",
    //     info: "免费接口随机延迟3-6分钟，实时接口请访问opencai.net或QQ:23081452(注明彩票或API)",
    //     data: [
    //         {
    //             expect: "2017063",
    //             opencode: "12,16,20,22,25,31+04",
    //             opentime: "2017-06-01 21:18:20",
    //             opentimestamp: 1496323100
    //         }
    //     ]
    // }
    // {
    //     code: 'ssq',
    //         type: '双色球',
    //     img: './src/static/images/ssq.webp',
    //     expect: "2017063",
    //     opencode: ['12', '16', '20', '22', '27', '31', '+04'],
    //     opentime: "2017-06-01 21:00:00",
    //     opentimestamp: 1496323100
    // }
    let newObj = {};
    newObj.code = obj.code;
    newObj.expect = obj.data[0].expect;
    newObj.opentime = obj.data[0].opentime;
    newObj.opentimestamp = obj.data[0].opentimestamp;

    newObj.opencode = str2Arr(obj.data[0].opencode);
    switch (true) {
        case newObj.code == "ssq" :
            newObj.type = "双色球";
            newObj.img = url + 'ssq.gif';
            //给双色球的蓝球做标识
            newObj.opencode[6] = newObj.opencode[6] + "+";
            break;
        case newObj.code == "dlt" :
            newObj.type = "超级大乐透";
            newObj.img = url + 'dlt.gif';
            //给大乐透的蓝球做标识
            newObj.opencode[5] = newObj.opencode[5] + "+";
            newObj.opencode[6] = newObj.opencode[6] + "+";
            break;
        case newObj.code == "pl3" :
            newObj.type = "排列3";
            newObj.img = url + 'pl3.gif';
            break;
        case newObj.code == "pl5" :
            newObj.type = "排列5";
            newObj.img = url + 'pl5.gif';
            break;
        case newObj.code == "qlc" :
            newObj.type = "七乐彩";
            newObj.img = url + 'qlc.gif';
            break;
        case newObj.code == "qxc" :
            newObj.type = "七星彩";
            newObj.img = url + 'qxc.gif';
            break;
        case newObj.code == "fc3d":
            newObj.type = "福彩3D";
            newObj.img = url + 'fc3d.gif';
    }
    return newObj;
}